package com.etc;

 
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
 
/**
 */
@RestController
public class SessionControllerset {
 
    @GetMapping("/test")
    public Map<String, Object> testSessionId(HttpServletRequest request) {
 
        Map<String, Object> sessionIdPortMap = new HashMap<String, Object>();
 
        // 获取session信息
        sessionIdPortMap.put("sessionId：", request.getSession().getId());
        sessionIdPortMap.put("服务器端口：", request.getServerPort());
 
        // 向session中保存用户信息 key规则： user + "_" + uid
        request.getSession().setAttribute("user_1", "{uid:1,username:zs@qq.com}");
 
        return sessionIdPortMap;
    }
 
 
}